package com.tools.middle.redis.client;

import com.fasterxml.jackson.core.type.TypeReference;
import com.tools.common.container.OwnPairs;
import com.tools.common.object.C;
import com.tools.common.object.Note;
import com.tools.common.object.ObjKit;
import redis.clients.jedis.params.ZAddParams;
import redis.clients.jedis.params.ZIncrByParams;
import redis.clients.jedis.ZParams;
import redis.clients.jedis.Tuple;

import java.util.Set;
import java.util.Map;

/**
 * Redis ZSet 有序集合类型的一些
 * 自定义封装的操作方法
 * */
@Note("Redis ZSet 有序集合类型的一些定义封装的操作方法")
abstract class TypeZSet extends TypeSet {

    TypeZSet() {}

    /* **********************************************************************************
     *
     *          同名 - 需要手动 close 的操作方法
     *
     * *********************************************************************************
     * */

    public long zadd(String key, double score, Object value) {
        DataTypeKit.default_checkKey(key);
        Long result = this.jedis().zadd(key, score, ObjKit.toStringEmptyString(value));
        return DataTypeKit.default_returnResultLong(result);
    }

    public long zadd(String key, Map<Object, Double> valueAndScores) {
        DataTypeKit.default_checkKey(key);
        Long result = this.jedis().zadd(key, DataTypeKit.default_asStringKeyMap(valueAndScores));
        return DataTypeKit.default_returnResultLong(result);
    }

    public long zadd(String key, OwnPairs<Object, Double> valueAndScores) {
        DataTypeKit.default_checkKey(key);
        Long result = this.jedis().zadd(key, DataTypeKit.default_asStringKeyMap(valueAndScores));
        return DataTypeKit.default_returnResultLong(result);
    }

    @Note("ZAddParams 可以设置 >、<、xx、nx 等等参数")
    public long zadd(String key, double score, Object value, ZAddParams params) {
        DataTypeKit.default_checkKey(key);
        if(params == null) return this.zadd(key, score, value);
        Long result = this.jedis().zadd(key, score, ObjKit.toStringEmptyString(value), params);
        return DataTypeKit.default_returnResultLong(result);
    }

    public long zadd(String key, Map<Object, Double> valueAndScores, ZAddParams params) {
        DataTypeKit.default_checkKey(key);
        if(params == null) return this.zadd(key, valueAndScores);
        Long result = this.jedis().zadd(key, DataTypeKit.default_asStringKeyMap(valueAndScores), params);
        return DataTypeKit.default_returnResultLong(result);
    }

    public long zadd(String key, OwnPairs<Object, Double> valueAndScores, ZAddParams params) {
        DataTypeKit.default_checkKey(key);
        if(params == null) return this.zadd(key, valueAndScores);
        Long result = this.jedis().zadd(key, DataTypeKit.default_asStringKeyMap(valueAndScores), params);
        return DataTypeKit.default_returnResultLong(result);
    }

    public long zcard(String key) {
        DataTypeKit.default_checkKey(key);
        Long result = this.jedis().zcard(key);
        return DataTypeKit.default_returnResultLong(result);
    }

    @Note("统计在 min ~ max 这个范围内的元素的个数")
    public long zcount(String key, double min, double max) {
        DataTypeKit.default_checkKey(key);
        Long count = this.jedis().zcount(key, min, max);
        return DataTypeKit.default_returnResultLong(count);
    }

    @Note("给 value 的分值加上 incrNum 的增量")
    public double zincrby(String key, double incrNum, Object value) {
        DataTypeKit.default_checkKey(key);
        Double score = this.jedis().zincrby(key, incrNum, ObjKit.toStringEmptyString(value));
        return DataTypeKit.default_returnDoubleScore(score);
    }

    @Note("ZIncrByParams 可以设置 xx、nx、incr 等参数")
    public double zincrby(String key, double incrNum, Object value, ZIncrByParams params) {
        DataTypeKit.default_checkKey(key);
        if(params == null) return this.zincrby(key, incrNum, value);
        Double score = this.jedis().zincrby(key, incrNum, ObjKit.toStringEmptyString(value), params);
        return DataTypeKit.default_returnDoubleScore(score);
    }

    @Note("返回有序集合中指定元素的排名")
    public long zrank(String key, Object value) {
        DataTypeKit.default_checkKey(key);
        Long ranking = this.jedis().zrank(key, ObjKit.toStringEmptyString(value));
        return DataTypeKit.default_returnTimeResult(ranking);
    }

    @Note("返回指定元素的排名，是由大到小递减的排名")
    public long zrevrank(String key, Object value) {
        DataTypeKit.default_checkKey(key);
        Long result = this.jedis().zrevrank(key, ObjKit.toStringEmptyString(value));
        return DataTypeKit.default_returnResultLong(result);
    }

    public long zrem(String key, Object value) {
        DataTypeKit.default_checkKey(key);
        Long result = this.jedis().zrem(key, ObjKit.toStringEmptyString(value));
        return DataTypeKit.default_returnResultLong(result);
    }

    public long zrem(String key, Object... values) {
        DataTypeKit.default_checkKey(key);
        Long result = this.jedis().zrem(key, DataTypeKit.default_asStringArray(values));
        return DataTypeKit.default_returnResultLong(result);
    }

    public long zrem(String key, Iterable values) {
        DataTypeKit.default_checkKey(key);
        Long result = this.jedis().zrem(key, DataTypeKit.default_asStringArray(values));
        return DataTypeKit.default_returnResultLong(result);
    }

    @Note("删除从 min 到 max 之间的所有元素")
    public long zremrangeByLex(String key, Object min, Object max) {
        DataTypeKit.default_checkKey(key);
        Long result = this.jedis().zremrangeByLex(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max));
        return DataTypeKit.default_returnResultLong(result);
    }

    @Note("删除排名为 start 到 stop 之间的所有元素")
    public long zremrangeByRank(String key, long start, long stop) {
        DataTypeKit.default_checkKey(key);
        Long result = this.jedis().zremrangeByRank(key, start, stop);
        return DataTypeKit.default_returnResultLong(result);
    }

    @Note("删除分数在 min 到 max 之间的所有元素")
    public long zremrangeByScore(String key, double min, double max) {
        DataTypeKit.default_checkKey(key);
        Long result = this.jedis().zremrangeByScore(key, min, max);
        return DataTypeKit.default_returnResultLong(result);
    }

    @Note("返回指定 value 的分数")
    public double zscore(String key, Object value) {
        DataTypeKit.default_checkKey(key);
        Double score = this.jedis().zscore(key, ObjKit.toStringEmptyString(value));
        return DataTypeKit.default_returnDoubleScore(score);
    }

    public Set<Object> zrange(String key, long start, long stop) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrange(key, start, stop);
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zrange(String key, long start, long stop, Class<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrange(key, start, stop);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrange(String key, long start, long stop, TypeReference<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrange(key, start, stop);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrange(String key, long start, long stop, C<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrange(key, start, stop);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    @Note("返回有序集合中元素排名在 min 到 max 之间的所有元素")
    public Set<Object> zrangeByLex(String key, Object min, Object max) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByLex(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max));
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zrangeByLex(String key, Object min, Object max, Class<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByLex(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrangeByLex(String key, Object min, Object max, TypeReference<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByLex(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrangeByLex(String key, Object min, Object max, C<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByLex(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    @Note("分页的方式分批返回 min 到 max 之间的元素")
    public Set<Object> zrangeByLex(String key, Object min, Object max, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByLex(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max), offset, count);
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zrangeByLex(String key, Object min, Object max, Class<T> valueType, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByLex(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max), offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrangeByLex(String key, Object min, Object max, TypeReference<T> valueType, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByLex(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max), offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrangeByLex(String key, Object min, Object max, C<T> valueType, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByLex(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max), offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    @Note("返回分数在 min 到 max 之间的所有元素")
    public Set<Object> zrangeByScore(String key, double min, double max) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, min, max);
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zrangeByScore(String key, double min, double max, Class<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, min, max);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrangeByScore(String key, double min, double max, TypeReference<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, min, max);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrangeByScore(String key, double min, double max, C<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, min, max);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    @Note("分页的方式分批返回分数在 min 和 max 之间的所有元素")
    public Set<Object> zrangeByScore(String key, double min, double max, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, min, max, offset, count);
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zrangeByScore(String key, double min, double max, Class<T> valueType, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, min, max, offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrangeByScore(String key, double min, double max, TypeReference<T> valueType, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, min, max, offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrangeByScore(String key, double min, double max, C<T> valueType, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, min, max, offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    @Note("返回元素排名在 min 和 max 之间的所有元素")
    public Set<Object> zrangeByScore(String key, Object min, Object max) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max));
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zrangeByScore(String key, Object min, Object max, Class<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrangeByScore(String key, Object min, Object max, TypeReference<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrangeByScore(String key, Object min, Object max, C<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    @Note("分页分批返回排名在 min 和 max 之间的所有元素")
    public Set<Object> zrangeByScore(String key, Object min, Object max, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max), offset, count);
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zrangeByScore(String key, Object min, Object max, Class<T> valueType, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max), offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrangeByScore(String key, Object min, Object max, TypeReference<T> valueType, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max), offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrangeByScore(String key, Object min, Object max, C<T> valueType, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrangeByScore(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max), offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    @Note("返回分数在 min 到 max 之间的所有元素和它的分数")
    public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max) {
        DataTypeKit.default_checkKey(key);
        return this.jedis().zrangeByScoreWithScores(key, min, max);
    }

    public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        return this.jedis().zrangeByScoreWithScores(key, min, max, offset, count);
    }

    @Note("返回元素排名在 min 到 max 之间的所有元素和它的分数")
    public Set<Tuple> zrangeByScoreWithScores(String key, Object min, Object max) {
        DataTypeKit.default_checkKey(key);
        return this.jedis().zrangeByScoreWithScores(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max));
    }

    public Set<Tuple> zrangeByScoreWithScores(String key, Object min, Object max, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        return this.jedis().zrangeByScoreWithScores(key, ObjKit.toStringEmptyString(min), ObjKit.toStringEmptyString(max), offset, count);
    }

    @Note("返回排名位于 start 到 stop 分值逆序的元素，逆序也就是分值从大到小")
    public Set<Object> zrevrange(String key, long start, long stop) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrange(key, start, stop);
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zrevrange(String key, long start, long stop, Class<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrange(key, start, stop);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrevrange(String key, long start, long stop, TypeReference<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrange(key, start, stop);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrevrange(String key, long start, long stop, C<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrange(key, start, stop);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    @Note("返回 max 到 min 之间的元素。也就是逆序的")
    public Set<Object> zrevrangeByLex(String key, Object max, Object min) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByLex(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min));
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zrevrangeByLex(String key, Object max, Object min, Class<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByLex(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrevrangeByLex(String key, Object max, Object min, TypeReference<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByLex(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrevrangeByLex(String key, Object max, Object min, C<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByLex(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    @Note("分页分批返回 max 到 min 之间的元素。也就是逆序的")
    public Set<Object> zrevrangeByLex(String key, Object max, Object min, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByLex(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min), offset, count);
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zrevrangeByLex(String key, Object max, Object min, int offset, int count, Class<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByLex(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min), offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrevrangeByLex(String key, Object max, Object min, int offset, int count, TypeReference<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByLex(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min), offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrevrangeByLex(String key, Object max, Object min, int offset, int count, C<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByLex(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min), offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    @Note("返回分数在 max 到 min 之家的所有元素，顺序是逆序的")
    public Set<Object> zrevrangeByScore(String key, double max, double min) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, max, min);
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zrevrangeByScore(String key, double max, double min, Class<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, max, min);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrevrangeByScore(String key, double max, double min, TypeReference<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, max, min);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrevrangeByScore(String key, double max, double min, C<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, max, min);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    @Note("分页分批返回分数在 max 到 min 之家的元素，顺序是逆序的")
    public Set<Object> zrevrangeByScore(String key, double max, double min, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, max, min, offset, count);
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zrevrangeByScore(String key, double max, double min, Class<T> valueType, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, max, min, offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrevrangeByScore(String key, double max, double min, TypeReference<T> valueType, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, max, min, offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrevrangeByScore(String key, double max, double min, C<T> valueType, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, max, min, offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    @Note("返回在 max 到 min 之间的元素，顺序是逆序的")
    public Set<Object> zrevrangeByScore(String key, Object max, Object min) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min));
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zrevrangeByScore(String key, Object max, Object min, Class<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrevrangeByScore(String key, Object max, Object min, TypeReference<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrevrangeByScore(String key, Object max, Object min, C<T> valueType) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    @Note("分页分批返回在 max 到 min 之间的元素，顺序是逆序的")
    public Set<Object> zrevrangeByScore(String key, Object max, Object min, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min), offset, count);
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zrevrangeByScore(String key, Object max, Object min, Class<T> valueType, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min), offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrevrangeByScore(String key, Object max, Object min, TypeReference<T> valueType, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min), offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zrevrangeByScore(String key, Object max, Object min, C<T> valueType, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        Set<String> res = this.jedis().zrevrangeByScore(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min), offset, count);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    @Note("返回排名在 start 到 top 之间的所有元素和它们的分数返回")
    public Set<Tuple> zrangeWithScores(String key, long start, long stop) {
        DataTypeKit.default_checkKey(key);
        return this.jedis().zrangeWithScores(key, start, stop);
    }

    @Note("返回排名在 start 到 top 之间的所有元素和它们的分数返回。但顺序是逆序的")
    public Set<Tuple> zrevrangeWithScores(String key, long start, long stop) {
        DataTypeKit.default_checkKey(key);
        return this.jedis().zrevrangeWithScores(key, start, stop);
    }

    @Note("返回分数在 max 到 min 之间的所有元素和它们的分数")
    public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min) {
        DataTypeKit.default_checkKey(key);
        return this.jedis().zrangeByScoreWithScores(key, max, min);
    }

    @Note("返回分数在 max 到 min 之间的所有元素和它们的分数")
    public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        return this.jedis().zrangeByScoreWithScores(key, max, min, offset, count);
    }

    @Note("返回分数在 max 到 min 之间的所有元素和它们的分数")
    public Set<Tuple> zrevrangeByScoreWithScores(String key, Object max, Object min) {
        DataTypeKit.default_checkKey(key);
        return this.jedis().zrangeByScoreWithScores(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min));
    }

    @Note("返回分数在 max 到 min 之间的所有元素和它们的分数")
    public Set<Tuple> zrevrangeByScoreWithScores(String key, Object max, Object min, int offset, int count) {
        DataTypeKit.default_checkKey(key);
        return this.jedis().zrangeByScoreWithScores(key, ObjKit.toStringEmptyString(max), ObjKit.toStringEmptyString(min), offset, count);
    }

    @Note("把多个集合的交集，然后将结果放到 targetKey 的集合中")
    public long zinterstore(String targetKey, String... srcKeys) {
        DataTypeKit.default_checkKey(targetKey);
        DataTypeKit.default_checkKeys(srcKeys);
        Long result = this.jedis().zinterstore(targetKey, srcKeys);
        return DataTypeKit.default_returnResultLong(result);
    }

    public long zinterstore(String targetKey, Iterable<String> srcKeys) {
        DataTypeKit.default_checkKey(targetKey);
        Long result = this.jedis().zinterstore(targetKey, DataTypeKit.default_asStringKeyArray(srcKeys));
        return DataTypeKit.default_returnResultLong(result);
    }


    @Note("把多个集合的交集，然后将结果放到 targetKey 的集合中。ZParams 有 SUM、MIN、MAX 等")
    public long zinterstore(String targetKey, ZParams params, String... srcKeys) {
        DataTypeKit.default_checkKey(targetKey);
        DataTypeKit.default_checkKeys(srcKeys);
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Long result = this.jedis().zinterstore(targetKey, params, srcKeys);
        return DataTypeKit.default_returnResultLong(result);
    }

    public long zinterstore(String targetKey, ZParams params, Iterable<String> srcKeys) {
        DataTypeKit.default_checkKey(targetKey);
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Long result = this.jedis().zinterstore(targetKey, params, DataTypeKit.default_asStringKeyArray(srcKeys));
        return DataTypeKit.default_returnResultLong(result);
    }

    @Note("返回多个集合的交集，其中的元素包含了分数。ZParams 有 SUM、MIN、MAX 等")
    public Set<Tuple> zinterWithScores(ZParams params, String... keys) {
        DataTypeKit.default_checkKeys(keys);
        DataTypeKit.default_checkZParamsIsNotNull(params);
        return this.jedis().zinterWithScores(params, keys);
    }

    public Set<Tuple> zinterWithScores(ZParams params, Iterable<String> keys) {
        DataTypeKit.default_checkZParamsIsNotNull(params);
        return this.jedis().zinterWithScores(params, DataTypeKit.default_asStringKeyArray(keys));
    }

    @Note("取多个有序集合的交集，ZParams 可以设置 MIN、MAX、SUM 等关系")
    public Set<Object> zinter(ZParams params, String... keys) {
        DataTypeKit.default_checkKeys(keys);
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zinter(params, keys);
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zinter(ZParams params, Class<T> valueType, String... keys) {
        DataTypeKit.default_checkKeys(keys);
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zinter(params, keys);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zinter(ZParams params, TypeReference<T> valueType, String... keys) {
        DataTypeKit.default_checkKeys(keys);
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zinter(params, keys);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zinter(ZParams params, C<T> valueType, String... keys) {
        DataTypeKit.default_checkKeys(keys);
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zinter(params, keys);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }


    public Set<Object> zinter(ZParams params, Iterable<String> keys) {
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zinter(params, DataTypeKit.default_asStringKeyArray(keys));
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zinter(ZParams params, Class<T> valueType, Iterable<String> keys) {
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zinter(params, DataTypeKit.default_asStringKeyArray(keys));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zinter(ZParams params, TypeReference<T> valueType, Iterable<String> keys) {
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zinter(params, DataTypeKit.default_asStringKeyArray(keys));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zinter(ZParams params, C<T> valueType, Iterable<String> keys) {
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zinter(params, DataTypeKit.default_asStringKeyArray(keys));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    @Note("取多个集合的并集，并将其保存至 tarKey 集合中")
    public long zunionstore(String tarKey, String... srcKeys) {
        DataTypeKit.default_checkKey(tarKey);
        DataTypeKit.default_checkKeys(srcKeys);
        Long result = this.jedis().zunionstore(tarKey, srcKeys);
        return DataTypeKit.default_returnResultLong(result);
    }

    public long zunionstore(String tarKey, Iterable<String> srcKeys) {
        DataTypeKit.default_checkKey(tarKey);
        Long result = this.jedis().zunionstore(tarKey, DataTypeKit.default_asStringKeyArray(srcKeys));
        return DataTypeKit.default_returnResultLong(result);
    }


    @Note("取多个集合的并集，并将其保存至 tarKey 集合中。其中 ZParams 可以设置 MIN、MAX、SUM 等关系")
    public long zunionstore(String tarKey, ZParams params, String... srcKeys) {
        DataTypeKit.default_checkKey(tarKey);
        DataTypeKit.default_checkKeys(srcKeys);
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Long result = this.jedis().zunionstore(tarKey, params, srcKeys);
        return DataTypeKit.default_returnResultLong(result);
    }

    public long zunionstore(String tarKey, ZParams params, Iterable<String> srcKeys) {
        DataTypeKit.default_checkKey(tarKey);
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Long result = this.jedis().zunionstore(tarKey, params, DataTypeKit.default_asStringKeyArray(srcKeys));
        return DataTypeKit.default_returnResultLong(result);
    }


    @Note("返回多个集合的并集的元素和分数")
    public Set<Tuple> zunionWithScores(ZParams params, String... keys) {
        DataTypeKit.default_checkKeys(keys);
        DataTypeKit.default_checkZParamsIsNotNull(params);
        return this.jedis().zunionWithScores(params, keys);
    }

    public Set<Tuple> zunionWithScores(ZParams params, Iterable<String> keys) {
        DataTypeKit.default_checkZParamsIsNotNull(params);
        return this.jedis().zunionWithScores(params, DataTypeKit.default_asStringArray(keys));
    }

    @Note("返回多个集合的并集，ZParams 可以设置 MIN、MAX、SUM 等关系")
    public Set<Object> zunion(ZParams params, String... keys) {
        DataTypeKit.default_checkKeys(keys);
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zunion(params, keys);
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zunion(ZParams params, Class<T> valueType, String... keys) {
        DataTypeKit.default_checkKeys(keys);
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zunion(params, keys);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zunion(ZParams params, TypeReference<T> valueType, String... keys) {
        DataTypeKit.default_checkKeys(keys);
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zunion(params, keys);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zunion(ZParams params, C<T> valueType, String... keys) {
        DataTypeKit.default_checkKeys(keys);
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zunion(params, keys);
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }


    public Set<Object> zunion(ZParams params, Iterable<String> keys) {
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zunion(params, DataTypeKit.default_asStringKeyArray(keys));
        return DataTypeKit.default_asObjectSet(res);
    }

    public <T> Set<T> zunion(ZParams params, Class<T> valueType, Iterable<String> keys) {
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zunion(params, DataTypeKit.default_asStringKeyArray(keys));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zunion(ZParams params, TypeReference<T> valueType, Iterable<String> keys) {
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zunion(params, DataTypeKit.default_asStringKeyArray(keys));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    public <T> Set<T> zunion(ZParams params, C<T> valueType, Iterable<String> keys) {
        DataTypeKit.default_checkZParamsIsNotNull(params);
        Set<String> res = this.jedis().zunion(params, DataTypeKit.default_asStringKeyArray(keys));
        return DataTypeKit.default_asSpecifyTypeSet(res, valueType);
    }

    /* **********************************************************************************
     *
     *          带【$】 - 自动 close 的操作方法
     *
     * *********************************************************************************
     * */

    public long zadd$(String key, double score, Object value) {
        try {
            return this.zadd(key, score, value);
        } finally {
            this.close();
        }
    }

    public long zadd$(String key, Map<Object, Double> valueAndScores) {
        try {
            return this.zadd(key, valueAndScores);
        } finally {
            this.close();
        }
    }

    public long zadd$(String key, OwnPairs<Object, Double> valueAndScores) {
        try {
            return this.zadd(key, valueAndScores);
        } finally {
            this.close();
        }
    }

    @Note("ZAddParams 可以设置 >、<、xx、nx 等等参数")
    public long zadd$(String key, double score, Object value, ZAddParams params) {
        try {
            return this.zadd(key, score, value, params);
        } finally {
            this.close();
        }
    }

    public long zadd$(String key, Map<Object, Double> valueAndScores, ZAddParams params) {
        try {
            return this.zadd(key, valueAndScores, params);
        } finally {
            this.close();
        }
    }

    public long zadd$(String key, OwnPairs<Object, Double> valueAndScores, ZAddParams params) {
        try {
            return this.zadd(key, valueAndScores, params);
        } finally {
            this.close();
        }
    }

    public long zcard$(String key) {
        try {
            return this.zcard(key);
        } finally {
            this.close();
        }
    }

    @Note("统计在 min ~ max 这个范围内的元素的个数")
    public long zcount$(String key, double min, double max) {
        try {
            return this.zcount(key, min, max);
        } finally {
            this.close();
        }
    }

    @Note("给 value 的分值加上 incrNum 的增量")
    public double zincrby$(String key, double incrNum, Object value) {
        try {
            return this.zincrby(key, incrNum, value);
        } finally {
            this.close();
        }
    }

    @Note("ZIncrByParams 可以设置 xx、nx、incr 等参数")
    public double zincrby$(String key, double incrNum, Object value, ZIncrByParams params) {
        try {
            return this.zincrby(key, incrNum, value, params);
        } finally {
            this.close();
        }
    }

    @Note("返回有序集合中指定元素的排名")
    public long zrank$(String key, Object value) {
        try {
            return this.zrank(key, value);
        } finally {
            this.close();
        }
    }

    @Note("返回指定元素的排名，是由大到小递减的排名")
    public long zrevrank$(String key, Object value) {
        try {
            return this.zrevrank(key, value);
        } finally {
            this.close();
        }
    }


    public long zrem$(String key, Object value) {
        try {
            return this.zrem(key, value);
        } finally {
            this.close();
        }
    }

    public long zrem$(String key, Object... values) {
        try {
            return this.zrem(key, values);
        } finally {
            this.close();
        }
    }

    public long zrem$(String key, Iterable values) {
        try {
            return this.zrem(key, values);
        } finally {
            this.close();
        }
    }

    @Note("删除从 min 到 max 之间的所有元素")
    public long zremrangeByLex$(String key, Object min, Object max) {
        try {
            return this.zremrangeByLex(key, min, max);
        } finally {
            this.close();
        }
    }

    @Note("删除排名为 start 到 stop 之间的所有元素")
    public long zremrangeByRank$(String key, long start, long stop) {
        try {
            return this.zremrangeByRank(key, start, stop);
        } finally {
            this.close();
        }
    }

    @Note("删除分数在 min 到 max 之间的所有元素")
    public long zremrangeByScore$(String key, double min, double max) {
        try {
            return this.zremrangeByScore(key, min, max);
        } finally {
            this.close();
        }
    }

    @Note("返回指定 value 的分数")
    public double zscore$(String key, Object value) {
        try {
            return this.zscore(key, value);
        } finally {
            this.close();
        }
    }

    public Set<Object> zrange$(String key, long start, long stop) {
        try {
            return this.zrange(key, start, stop);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrange$(String key, long start, long stop, Class<T> valueType) {
        try {
            return this.zrange(key, start, stop, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrange$(String key, long start, long stop, TypeReference<T> valueType) {
        try {
            return this.zrange(key, start, stop, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrange$(String key, long start, long stop, C<T> valueType) {
        try {
            return this.zrange(key, start, stop, valueType);
        } finally {
            this.close();
        }
    }


    @Note("返回有序集合中元素排名在 min 到 max 之间的所有元素")
    public Set<Object> zrangeByLex$(String key, Object min, Object max) {
        try {
            return this.zrangeByLex(key, min, max);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByLex$(String key, Object min, Object max, Class<T> valueType) {
        try {
            return this.zrangeByLex(key, min, max, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByLex$(String key, Object min, Object max, TypeReference<T> valueType) {
        try {
            return this.zrangeByLex(key, min, max, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByLex$(String key, Object min, Object max, C<T> valueType) {
        try {
            return this.zrangeByLex(key, min, max, valueType);
        } finally {
            this.close();
        }
    }

    @Note("分页的方式分批返回 min 到 max 之间的元素")
    public Set<Object> zrangeByLex$(String key, Object min, Object max, int offset, int count) {
        try {
            return this.zrangeByLex(key, min, max, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByLex$(String key, Object min, Object max, Class<T> valueType, int offset, int count) {
        try {
            return this.zrangeByLex(key, min, max, valueType, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByLex$(String key, Object min, Object max, TypeReference<T> valueType, int offset, int count) {
        try {
            return this.zrangeByLex(key, min, max, valueType, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByLex$(String key, Object min, Object max, C<T> valueType, int offset, int count) {
        try {
            return this.zrangeByLex(key, min, max, valueType, offset, count);
        } finally {
            this.close();
        }
    }


    @Note("返回分数在 min 到 max 之间的所有元素")
    public Set<Object> zrangeByScore$(String key, double min, double max) {
        try {
            return this.zrangeByScore(key, min, max);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByScore$(String key, double min, double max, Class<T> valueType) {
        try {
            return this.zrangeByScore(key, min, max, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByScore$(String key, double min, double max, TypeReference<T> valueType) {
        try {
            return this.zrangeByScore(key, min, max, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByScore$(String key, double min, double max, C<T> valueType) {
        try {
            return this.zrangeByScore(key, min, max, valueType);
        } finally {
            this.close();
        }
    }


    @Note("分页的方式分批返回分数在 min 和 max 之间的所有元素")
    public Set<Object> zrangeByScore$(String key, double min, double max, int offset, int count) {
        try {
            return this.zrangeByScore(key, min, max, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByScore$(String key, double min, double max, Class<T> valueType, int offset, int count) {
        try {
            return this.zrangeByScore(key, min, max, valueType, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByScore$(String key, double min, double max, TypeReference<T> valueType, int offset, int count) {
        try {
            return this.zrangeByScore(key, min, max, valueType, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByScore$(String key, double min, double max, C<T> valueType, int offset, int count) {
        try {
            return this.zrangeByScore(key, min, max, valueType, offset, count);
        } finally {
            this.close();
        }
    }


    @Note("返回元素排名在 min 和 max 之间的所有元素")
    public Set<Object> zrangeByScore$(String key, Object min, Object max) {
        try {
            return this.zrangeByScore(key, min, max);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByScore$(String key, Object min, Object max, Class<T> valueType) {
        try {
            return this.zrangeByScore(key, min, max, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByScore$(String key, Object min, Object max, TypeReference<T> valueType) {
        try {
            return this.zrangeByScore(key, min, max, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByScore$(String key, Object min, Object max, C<T> valueType) {
        try {
            return this.zrangeByScore(key, min, max, valueType);
        } finally {
            this.close();
        }
    }

    @Note("分页分批返回排名在 min 和 max 之间的所有元素")
    public Set<Object> zrangeByScore$(String key, Object min, Object max, int offset, int count) {
        try {
            return this.zrangeByScore(key, min, max, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByScore$(String key, Object min, Object max, Class<T> valueType, int offset, int count) {
        try {
            return this.zrangeByScore(key, min, max, valueType, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByScore$(String key, Object min, Object max, TypeReference<T> valueType, int offset, int count) {
        try {
            return this.zrangeByScore(key, min, max, valueType, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrangeByScore$(String key, Object min, Object max, C<T> valueType, int offset, int count) {
        try {
            return this.zrangeByScore(key, min, max, valueType, offset, count);
        } finally {
            this.close();
        }
    }

    @Note("返回分数在 min 到 max 之间的所有元素和它的分数")
    public Set<Tuple> zrangeByScoreWithScores$(String key, double min, double max) {
        try {
            return this.zrangeByScoreWithScores(key, min, max);
        } finally {
            this.close();
        }
    }

    public Set<Tuple> zrangeByScoreWithScores$(String key, double min, double max, int offset, int count) {
        try {
            return this.zrangeByScoreWithScores(key, min, max, offset, count);
        } finally {
            this.close();
        }
    }

    @Note("返回元素排名在 min 到 max 之间的所有元素和它的分数")
    public Set<Tuple> zrangeByScoreWithScores$(String key, Object min, Object max) {
        try {
            return this.zrangeByScoreWithScores(key, min, max);
        } finally {
            this.close();
        }
    }

    public Set<Tuple> zrangeByScoreWithScores$(String key, Object min, Object max, int offset, int count) {
        try {
            return this.zrangeByScoreWithScores(key, min, max, offset, count);
        } finally {
            this.close();
        }
    }

    @Note("返回排名位于 start 到 stop 分值逆序的元素，逆序也就是分值从大到小")
    public Set<Object> zrevrange$(String key, long start, long stop) {
        try {
            return this.zrevrange(key, start, stop);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrange$(String key, long start, long stop, Class<T> valueType) {
        try {
            return this.zrevrange(key, start, stop, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrange$(String key, long start, long stop, TypeReference<T> valueType) {
        try {
            return this.zrevrange(key, start, stop, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrange$(String key, long start, long stop, C<T> valueType) {
        try {
            return this.zrevrange(key, start, stop, valueType);
        } finally {
            this.close();
        }
    }

    @Note("返回 max 到 min 之间的元素。也就是逆序的")
    public Set<Object> zrevrangeByLex$(String key, Object max, Object min) {
        try {
            return this.zrevrangeByLex(key, max, min);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByLex$(String key, Object max, Object min, Class<T> valueType) {
        try {
            return this.zrevrangeByLex(key, max, min, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByLex$(String key, Object max, Object min, TypeReference<T> valueType) {
        try {
            return this.zrevrangeByLex(key, max, min, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByLex$(String key, Object max, Object min, C<T> valueType) {
        try {
            return this.zrevrangeByLex(key, max, min, valueType);
        } finally {
            this.close();
        }
    }

    @Note("分页分批返回 max 到 min 之间的元素。也就是逆序的")
    public Set<Object> zrevrangeByLex$(String key, Object max, Object min, int offset, int count) {
        try {
            return this.zrevrangeByLex(key, max, min, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByLex$(String key, Object max, Object min, int offset, int count, Class<T> valueType) {
        try {
            return this.zrevrangeByLex(key, max, min, offset, count, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByLex$(String key, Object max, Object min, int offset, int count, TypeReference<T> valueType) {
        try {
            return this.zrevrangeByLex(key, max, min, offset, count, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByLex$(String key, Object max, Object min, int offset, int count, C<T> valueType) {
        try {
            return this.zrevrangeByLex(key, max, min, offset, count, valueType);
        } finally {
            this.close();
        }
    }


    @Note("返回分数在 max 到 min 之家的所有元素，顺序是逆序的")
    public Set<Object> zrevrangeByScore$(String key, double max, double min) {
        try {
            return this.zrevrangeByScore(key, max, min);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByScore$(String key, double max, double min, Class<T> valueType) {
        try {
            return this.zrevrangeByScore(key, max, min, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByScore$(String key, double max, double min, TypeReference<T> valueType) {
        try {
            return this.zrevrangeByScore(key, max, min, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByScore$(String key, double max, double min, C<T> valueType) {
        try {
            return this.zrevrangeByScore(key, max, min, valueType);
        } finally {
            this.close();
        }
    }

    @Note("分页分批返回分数在 max 到 min 之家的元素，顺序是逆序的")
    public Set<Object> zrevrangeByScore$(String key, double max, double min, int offset, int count) {
        try {
            return this.zrevrangeByScore(key, max, min, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByScore$(String key, double max, double min, Class<T> valueType, int offset, int count) {
        try {
            return this.zrevrangeByScore(key, max, min, valueType, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByScore$(String key, double max, double min, TypeReference<T> valueType, int offset, int count) {
        try {
            return this.zrevrangeByScore(key, max, min, valueType, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByScore$(String key, double max, double min, C<T> valueType, int offset, int count) {
        try {
            return this.zrevrangeByScore(key, max, min, valueType, offset, count);
        } finally {
            this.close();
        }
    }


    @Note("返回在 max 到 min 之间的元素，顺序是逆序的")
    public Set<Object> zrevrangeByScore$(String key, Object max, Object min) {
        try {
            return this.zrevrangeByScore(key, max, min);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByScore$(String key, Object max, Object min, Class<T> valueType) {
        try {
            return this.zrevrangeByScore(key, max, min, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByScore$(String key, Object max, Object min, TypeReference<T> valueType) {
        try {
            return this.zrevrangeByScore(key, max, min, valueType);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByScore$(String key, Object max, Object min, C<T> valueType) {
        try {
            return this.zrevrangeByScore(key, max, min, valueType);
        } finally {
            this.close();
        }
    }

    @Note("分页分批返回在 max 到 min 之间的元素，顺序是逆序的")
    public Set<Object> zrevrangeByScore$(String key, Object max, Object min, int offset, int count) {
        try {
            return this.zrevrangeByScore(key, max, min, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByScore$(String key, Object max, Object min, Class<T> valueType, int offset, int count) {
        try {
            return this.zrevrangeByScore(key, max, min, valueType, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByScore$(String key, Object max, Object min, TypeReference<T> valueType, int offset, int count) {
        try {
            return this.zrevrangeByScore(key, max, min, valueType, offset, count);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zrevrangeByScore$(String key, Object max, Object min, C<T> valueType, int offset, int count) {
        try {
            return this.zrevrangeByScore(key, max, min, valueType, offset, count);
        } finally {
            this.close();
        }
    }


    @Note("返回排名在 start 到 top 之间的所有元素和它们的分数返回")
    public Set<Tuple> zrangeWithScores$(String key, long start, long stop) {
        try {
            return this.zrangeWithScores(key, start, stop);
        } finally {
            this.close();
        }
    }

    @Note("返回排名在 start 到 top 之间的所有元素和它们的分数返回。但顺序是逆序的")
    public Set<Tuple> zrevrangeWithScores$(String key, long start, long stop) {
        try {
            return this.zrevrangeWithScores(key, start, stop);
        } finally {
            this.close();
        }
    }

    @Note("返回分数在 max 到 min 之间的所有元素和它们的分数")
    public Set<Tuple> zrevrangeByScoreWithScores$(String key, double max, double min) {
        try {
            return this.zrevrangeByScoreWithScores(key, max, min);
        } finally {
            this.close();
        }
    }

    @Note("返回分数在 max 到 min 之间的所有元素和它们的分数")
    public Set<Tuple> zrevrangeByScoreWithScores$(String key, double max, double min, int offset, int count) {
        try {
            return this.zrevrangeByScoreWithScores(key, max, min, offset, count);
        } finally {
            this.close();
        }
    }

    @Note("返回分数在 max 到 min 之间的所有元素和它们的分数")
    public Set<Tuple> zrevrangeByScoreWithScores$(String key, Object max, Object min) {
        try {
            return this.zrevrangeByScoreWithScores(key, max, min);
        } finally {
            this.close();
        }
    }

    @Note("返回分数在 max 到 min 之间的所有元素和它们的分数")
    public Set<Tuple> zrevrangeByScoreWithScores$(String key, Object max, Object min, int offset, int count) {
        try {
            return this.zrevrangeByScoreWithScores(key, max, min, offset, count);
        } finally {
            this.close();
        }
    }


    @Note("把多个集合的交集，然后将结果放到 targetKey 的集合中")
    public long zinterstore$(String targetKey, String... srcKeys) {
        try {
            return this.zinterstore(targetKey, srcKeys);
        } finally {
            this.close();
        }
    }

    public long zinterstore$(String targetKey, Iterable<String> srcKeys) {
        try {
            return this.zinterstore(targetKey, srcKeys);
        } finally {
            this.close();
        }
    }


    @Note("把多个集合的交集，然后将结果放到 targetKey 的集合中。ZParams 有 SUM、MIN、MAX 等")
    public long zinterstore$(String targetKey, ZParams params, String... srcKeys) {
        try {
            return this.zinterstore(targetKey, params, srcKeys);
        } finally {
            this.close();
        }
    }

    public long zinterstore$(String targetKey, ZParams params, Iterable<String> srcKeys) {
        try {
            return this.zinterstore(targetKey, params, srcKeys);
        } finally {
            this.close();
        }
    }

    @Note("返回多个集合的交集，其中的元素包含了分数。ZParams 有 SUM、MIN、MAX 等")
    public Set<Tuple> zinterWithScores$(ZParams params, String... keys) {
        try {
            return this.zinterWithScores(params, keys);
        } finally {
            this.close();
        }
    }

    public Set<Tuple> zinterWithScores$(ZParams params, Iterable<String> keys) {
        try {
            return this.zinterWithScores(params, keys);
        } finally {
            this.close();
        }
    }


    @Note("取多个有序集合的交集，ZParams 可以设置 MIN、MAX、SUM 等关系")
    public Set<Object> zinter$(ZParams params, String... keys) {
        try {
            return this.zinter(params, keys);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zinter$(ZParams params, Class<T> valueType, String... keys) {
        try {
            return this.zinter(params, valueType, keys);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zinter$(ZParams params, TypeReference<T> valueType, String... keys) {
        try {
            return this.zinter(params, valueType, keys);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zinter$(ZParams params, C<T> valueType, String... keys) {
        try {
            return this.zinter(params, valueType, keys);
        } finally {
            this.close();
        }
    }


    public Set<Object> zinter$(ZParams params, Iterable<String> keys) {
        try {
            return this.zinter(params, keys);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zinter$(ZParams params, Class<T> valueType, Iterable<String> keys) {
        try {
            return this.zinter(params, valueType, keys);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zinter$(ZParams params, TypeReference<T> valueType, Iterable<String> keys) {
        try {
            return this.zinter(params, valueType, keys);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zinter$(ZParams params, C<T> valueType, Iterable<String> keys) {
        try {
            return this.zinter(params, valueType, keys);
        } finally {
            this.close();
        }
    }

    @Note("取多个集合的并集，并将其保存至 tarKey 集合中")
    public long zunionstore$(String tarKey, String... srcKeys) {
        try {
            return this.zunionstore(tarKey, srcKeys);
        } finally {
            this.close();
        }
    }

    public long zunionstore$(String tarKey, Iterable<String> srcKeys) {
        try {
            return this.zunionstore(tarKey, srcKeys);
        } finally {
            this.close();
        }
    }


    @Note("取多个集合的并集，并将其保存至 tarKey 集合中。其中 ZParams 可以设置 MIN、MAX、SUM 等关系")
    public long zunionstore$(String tarKey, ZParams params, String... srcKeys) {
        try {
            return this.zunionstore(tarKey, params, srcKeys);
        } finally {
            this.close();
        }
    }

    public long zunionstore$(String tarKey, ZParams params, Iterable<String> srcKeys) {
        try {
            return this.zunionstore(tarKey, params, srcKeys);
        } finally {
            this.close();
        }
    }


    @Note("返回多个集合的并集的元素和分数")
    public Set<Tuple> zunionWithScores$(ZParams params, String... keys) {
        try {
            return this.zunionWithScores(params, keys);
        } finally {
            this.close();
        }
    }

    public Set<Tuple> zunionWithScores$(ZParams params, Iterable<String> keys) {
        try {
            return this.zunionWithScores(params, keys);
        } finally {
            this.close();
        }
    }

    @Note("返回多个集合的并集，ZParams 可以设置 MIN、MAX、SUM 等关系")
    public Set<Object> zunion$(ZParams params, String... keys) {
        try {
            return this.zunion(params, keys);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zunion$(ZParams params, Class<T> valueType, String... keys) {
        try {
            return this.zunion(params, valueType, keys);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zunion$(ZParams params, TypeReference<T> valueType, String... keys) {
        try {
            return this.zunion(params, valueType, keys);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zunion$(ZParams params, C<T> valueType, String... keys) {
        try {
            return this.zunion(params, valueType, keys);
        } finally {
            this.close();
        }
    }


    public Set<Object> zunion$(ZParams params, Iterable<String> keys) {
        try {
            return this.zunion(params, keys);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zunion$(ZParams params, Class<T> valueType, Iterable<String> keys) {
        try {
            return this.zunion(params, valueType, keys);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zunion$(ZParams params, TypeReference<T> valueType, Iterable<String> keys) {
        try {
            return this.zunion(params, valueType, keys);
        } finally {
            this.close();
        }
    }

    public <T> Set<T> zunion$(ZParams params, C<T> valueType, Iterable<String> keys) {
        try {
            return this.zunion(params, valueType, keys);
        } finally {
            this.close();
        }
    }

}
